home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 11
/
Mac Magazin and MacEasy Magazine CD - Issue 11.iso
/
Sharewarebibliothek
/
Entwickler
/
WASTE 1.1b1 Distribution
/
Demo Source
/
WEDemoSounds.p
< prev
next >
Wrap
Text File
|
1995-06-01
|
2KB
|
83 lines
unit WEDemoSounds;
{ WASTE DEMO PROJECT: }
{ Object Handlers for embedded sounds }
{ Copyright © 1993-1995 Marco Piovanelli }
{ All Rights Reserved }
{ Based on code written by by Michael F. Kamprath, kamprath@earthlink.net }
interface
uses
WEDemoIntf;
function HandleNewSound (var defaultObjectSize: Point;
objectRef: WEObjectReference): OSErr;
function HandleDrawSound (destRect: Rect;
objectRef: WEObjectReference): OSErr;
function HandleClickSound (hitPt: Point;
modifiers: Integer;
clickTime: LongInt;
objectRef: WEObjectReference): Boolean;
implementation
uses
Icons, Sound;
const
kSoundIconID = 550; { resource ID of sound icon family resources }
function HandleNewSound (var defaultObjectSize: Point;
objectRef: WEObjectReference): OSErr;
begin
{ we'll use a standard 32x32 icon to represent the sound object }
defaultObjectSize.v := 32;
defaultObjectSize.h := 32;
{ return error code }
HandleNewSound := noErr;
end; { HandleNewSound }
function HandleDrawSound (destRect: Rect;
objectRef: WEObjectReference): OSErr;
begin
{ draw the sound icon }
HandleDrawSound := PlotIconID(destRect, atBottom, ttNone, kSoundIconID);
end; { HandleDrawSound }
function HandleClickSound (hitPt: Point;
modifiers: Integer;
clickTime: LongInt;
objectRef: WEObjectReference): Boolean;
var
theSound: SndListHandle;
begin
{ WASTE sets the low bit of modifiers on double (multiple) clicks }
if (BAND(modifiers, $0001) <> 0) then
begin
{ get a handle to the object data (in this case, a 'snd ' handle) }
theSound := SndListHandle(WEGetObjectDataHandle(objectRef));
{ play the sound }
if (SndPlay(nil, theSound, false) <> noErr) then
;
{ return TRUE so WASTE knows we handled the click }
HandleClickSound := true;
end
else
{ not a double click: let WASTE handle the mouse-down }
HandleClickSound := false;
end; { HandleClickSound }
end.